package com.gbdata.zuul;

import com.gbdata.zuul.filter.CustomFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/gbdata/path"})
public class PathCheckEndpoint {
    @Autowired
    private CustomFilter customFilter;
    @Autowired
    ZuulProperties properties;

    public PathCheckEndpoint() {
    }

    @GetMapping({"/"})
    public String getPathSet() {
        StringBuilder sb = new StringBuilder();
        this.customFilter.pathSet.forEach((s) -> {
            sb.append(s).append("\n");
        });
        return sb.toString();
    }

    @ResponseBody
    @GetMapping({"/cfg"})
    public String getConfig() {
        StringBuilder sb = new StringBuilder();
        sb.append((new ZuulProperties()).toString());
        sb.append(this.properties.toString());
        return sb.toString();
    }
}
